Encryption and Decryption of File Using Affine Ciphering

This is a Python program using which you can encrypt and decrypt a file using the Affine Cipher which will help to secure your confidential data. 

Requirements:-

To run this code following libraries should be installed:-

1. SymPy -> This library is used for symbolic Mathematics and in this project will help to get prime numbers within a range using only the library package


Code Instruction:-

1. You can Provide the FILE path or File Name (but remember that file should be in the same directory)

2. The File Should end with the extension (Recommend to use a .txt file)

3. After that provide any number

4. Then You will get Your encrypted and Decrypted Text




How is Affine Encryption & Decryption Working:

Affine Cipher is the combination of Multiplicative Cipher and Caesar Cipher algorithm.

Encryption:

It uses modular arithmetic to transform the integer that each plaintext letter corresponds to into another integer that correspond to a ciphertext letter. The encryption function for a single letter is

E(X) = (ax+b)mod m
modulus m: Weight of Alphabet
a and b: Cipher Key
Decryption

In deciphering the ciphertext, we must perform the opposite functions on the ciphertext to retrieve the plaintext. Once again, the first step is to convert each of the ciphertext letters into their integer values. The decryption function is

D (x) = a^-1(x-b)mod m
a^-1 : modular multiplicative inverse of a modulo m. i.e., it satisfies the equation
1 = a a^-1 mod m .